package com.my12306.train.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.my12306.train.model.entity.SeatEntity;
import com.my12306.train.model.vo.PageSeatVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 席位信息表
 *
 * @Author:苏牧夕
 * @email
 * @date 2020-07-24 20:58:07
 */
@Mapper
public interface SeatDao extends BaseMapper<SeatEntity> {

    List<SeatEntity> querySeatsByPage(@Param("pageVo") PageSeatVo pageVo, @Param("logicDelete") Integer logicDelete);

    /**
     * 根据条件动态查询数据总数据量
     *
     * @param pageVo
     * @param logicDelete
     * @return
     */
    Integer querySeatsCountByPage(@Param("pageVo") PageSeatVo pageVo, @Param("logicDelete") Integer logicDelete);

    /**
     * @param seatIds
     * @param logicDelete
     */
    void updateBatchSeatBySeatIds(@Param("list") List<Long> seatIds, @Param("logicDelete") Integer logicDelete);

    /**
     * 批量添加
     *
     * @param seatEntities
     */
    void saveBatchSeats(@Param("list") List<SeatEntity> seatEntities);

    /**
     * 根据时间查询当天的所有数据
     *
     * @param toDaty
     * @param afterDay
     * @param logicDelete
     */
    List<SeatEntity> querySeatsByToDay(@Param("startDate") Date toDaty, @Param("endDate") Date afterDay, @Param("logicDelete") Integer logicDelete);

    /**
     * 查询所有可预售的时间点
     * @param logicDelete
     * @return
     */
    List<Date> queryAllSeatDate(@Param("logicDelete") Integer logicDelete);

    /**
     * 根据发车时间和售票状态来检索 检索票据
     * @param startDate
     * @param logicDelete
     * @param sold
     * @return
     */
    List<SeatEntity> querySeatsByStartDate(@Param("startDate") String startDate, @Param("logicDelete") Integer logicDelete, @Param("sold") Integer sold);

    /**
     * 根据车次代码和车厢编号删除席位信息
     * @param trainCode
     * @param coachNumber
     * @param logicDelete
     */
    void deleteBatchSeatsByTrainCodeAndCoachNumber(@Param("trainCodes") List<String> trainCode, @Param("coachNumbers") List<Long> coachNumber, @Param("logicDelete") int logicDelete, @Param("showStatus") int showStatus);

    /**
     * 批量修改
     * @param ids
     */
    void updateBatchSeate(@Param("seatEntity") SeatEntity seatEntity, @Param("list") List<Long> ids);

    /**
     * 根据 时间\销售状态\车次代码\起始站来查询席位
     * @param strDate
     * @param trainCodes
     * @param seateNotSold
     * @param fromStation
     * @param logicDelete
     * @return
     */
    List<SeatEntity> querySeateByStartDateAndTrainCode(@Param("strDate") String strDate, @Param("trainCodes") List<String> trainCodes, @Param("seateNotSold") Integer seateNotSold, @Param("fromStation") String fromStation, @Param("logicDelete") Integer logicDelete);

    List<SeatEntity> queryTicketSeatByStartDateAndTrainCode(@Param("strDate") String strDate, @Param("trainCodes") List<String> trainCodes, @Param("seateNotSold") Integer seateNotSold, @Param("fromStation") String fromStation, @Param("logicDelete") Integer logicDelete);

    List<SeatEntity> queryTicketSeat(@Param("strDate") String strDate, @Param("trainCode") String trainCode, @Param("stations") List<String> stations, @Param("seateSold") Integer seateSold, @Param("logicDelete") Integer logicDelete);    /**
     *
     * @param strDate
     * @param trainCode
     * @param stations
     * @param seateSold
     * @param logicDelete
     * @return
     */
    List<SeatEntity> querySeateSoledByTrainCodeAndStations(@Param("strDate") String strDate, @Param("trainCode") String trainCode, @Param("stations") List<String> stations, @Param("seateSold") Integer seateSold, @Param("logicDelete") Integer logicDelete);
}
